<?php

namespace app\index\controller;

use app\common\model\Adver;
use app\common\model\Sort;
use think\Controller;
use think\Request;
use think\facade\Session;
use app\common\model\Question;

class Base extends Controller
{
    /**
     * 初始化页面所有内容
     * @return void
     */
    protected function initialize()
    {
        //如果已登陆则头部修改
        if (Session::has('main_user')) {
            $this->assign('login', Session::get('main_user'));
        } else {
            $this->assign('login', '0');
        }
        $que = new Question;
        //随机模块
        $rand_list = $que->get_rand();
        $this->assign('rand_list', $rand_list);

        //广告模块
        $adver = Adver::select();
        // dump($adver);

        $this->assign('adver', $adver);
        $sort = new Sort();
        $sort_list_menu = $sort->get_Sort_menu();
        $this->assign('sort_list_menu', $sort_list_menu);

    }
}
